const {
	Controller
} = require("uni-cloud-router");

module.exports = class EncryptUtillsController extends(
	Controller
) {
	async sha256WithRsaToBase64(event, context) {
		let data = event.data
		let dataInfo = data.dataInfo,
			privateKeyFileName = data.privateKeyFileName,
			privateKey = data.privateKey
		return this.service.encryptUtills.sha256WithRsaToBase64(dataInfo, privateKeyFileName, privateKey)
	}

	async sha256To(event) {
		let data = event.data
		let dataInfo = data.dataInfo
		return this.service.encryptUtills.sha256To(dataInfo)
	}

	async encryptSensitiveInfoWx(event) {
		let data = event.data
		let dataInfo = data.dataInfo,
			privateKeyFileName = data.privateKeyFileName,
			privateKey = data.privateKey
		return this.service.encryptUtills.encryptSensitiveInfoWx(dataInfo, privateKeyFileName, privateKey)
	}
	
	async decodeV3CertificatesWx(event){
		let data = event.data
		let ciphertext = data.ciphertext,
			nonce = data.nonce,
			apiV3Key = data.apiV3Key,
			associated_data = data.associated_data
		return this.service.encryptUtills.decodeV3CertificatesWx(ciphertext, nonce, apiV3Key, associated_data)
	}
};
